#ifndef AUTHDATASCOP_H
#define AUTHDATASCOP_H

#include "api/systemManager/rolemanagerapi.h"
#include <QWidget>
#include <Entity/TreeSelect.h>

namespace Ui {
class AuthDataScop;
}

class AuthDataScop : public QDialog
{
    Q_OBJECT

public:
    explicit AuthDataScop(QString id,QWidget *parent = nullptr);
    ~AuthDataScop();

private slots:
    void on_comboBox_currentIndexChanged(int index);
    void treeItemChanged(QTreeWidgetItem *item,int column);
    void itemExpanded(QTreeWidgetItem *item);
    void itemCollapsed(QTreeWidgetItem *item);
    void on_pushButton_cancel_clicked();

    void on_checkBox_expand_clicked();

    void on_checkBox_fatherAndSon_clicked();

    void on_checkBox_selectAll_clicked();

    void on_btn_ok_clicked();

private:
    Ui::AuthDataScop *ui;
    RoleManagerApi roleManagerApi;
    Role *role;
    QString id;
    int treeNodeNum = 0;
    bool flag = 0;
    Utils utils;
    bool fatherAndSonLink = 1;

    void init();
    //递归设置部门树菜单
    void setTreeMenu(QList<TreeSelect> *treeList,QTreeWidgetItem *menu);
    //回显数据权限部门树
    void backShouDept(QTreeWidgetItem *item,QJsonArray data);
    //得到选中的部门树的id
    void getTreeIds(QList<int> &list,QTreeWidgetItem *item);
};

#endif // AUTHDATASCOP_H
